/*******************************************************************************
Paper: Does the Production Approach to Markup Estimation Match a Stylized Fact?
Description: Imports income data from Excel and saves a processed version
Author: Tove Forsbacka
Last Updated: 15 February 2026
*******************************************************************************/

* Setup and environment control 
clear
set more off
capture log close 

* Define path and load the data
*cd "PROJECT_PATH"
import excel "income.xlsx", sheet("HE0110K1") cellrange(A3:AH293) firstrow

drop B C D E F G H I J K L

rename A Kommunkod 
rename M y1998
rename N y1999
rename O y2000
rename P y2001
rename Q y2002
rename R y2003
rename S y2004
rename T y2005
rename U y2006
rename V y2007
rename W y2008
rename X y2009
rename Y y2010
rename Z y2011
rename AA y2012
rename AB y2013
rename AC y2014
rename AD y2015
rename AE y2016
rename AF y2017
rename AG y2018
rename AH y2019

replace y1998="." if y1998==".."
replace y1999="." if y1999==".."
replace y2000="." if y2000==".."
replace y2001="." if y2001==".."

destring Kommunkod, gen(nKommunkod)
drop Kommunkod
rename nKommunkod Kommunkod

destring y1998, gen(ny1998)
drop y1998
rename ny1998 y1998

destring y1999, gen(ny1999)
drop y1999
rename ny1999 y1999

destring y2000, gen(ny2000)
drop y2000
rename ny2000 y2000

destring y2001, gen(ny2001)
drop y2001
rename ny2001 y2001

reshape long y, i(Kommunkod) j(year)

rename y income

* Saving the data
save "income.dta", replace